
// ***********************************************************************
// AUTO GENERATED CLASS - Do Not Modify this file, if needed modify .tt
// ***********************************************************************
// Assembly         : InnovaApp_DomainLayer
// Author           : LJO+01
// Created          : 11/09/2013 10:32:08
// ***********************************************************************
// <copyright file="N.A." company="Copyright © Innovacall 2011">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary>
// Domain layer  
// DomainClass
// </summary>
// ***********************************************************************

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;


namespace InnovaApp.Layers.DomainLayer
{
    /// <summary>
    /// Class ContactTelecom
    /// </summary>
    [Serializable]
    public partial class ContactTelecom : _DomainLayer_Base
    {
        #region Primitive Properties
    	
        /// <summary>
        /// Gets or sets Id.
        /// </summary>
        /// <value>The Id.</value>
        public virtual int Id
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FK_Contact.
        /// </summary>
        /// <value>The FK_Contact.</value>
        /// <remarks>
        /// Foregn key of ContactTelecom
        /// 
        /// </remarks>
        public virtual int FK_Contact
        {
            get { return _fK_Contact; }
            set
            {
                if (_fK_Contact != value)
                {
                    if (Contact != null && Contact.Id != value)
                    {
                        Contact = null;
                    }
                    _fK_Contact = value;
                }
            }
        }
        private int _fK_Contact;
    	
        /// <summary>
        /// Gets or sets FK_TelecomType.
        /// </summary>
        /// <value>The FK_TelecomType.</value>
        /// <remarks>
        /// Foregn key of ContactTelecom
        /// 
        /// </remarks>
        public virtual int FK_TelecomType
        {
            get { return _fK_TelecomType; }
            set
            {
                if (_fK_TelecomType != value)
                {
                    if (TelecomType != null && TelecomType.Id != value)
                    {
                        TelecomType = null;
                    }
                    _fK_TelecomType = value;
                }
            }
        }
        private int _fK_TelecomType;
    	
        /// <summary>
        /// Gets or sets Value.
        /// </summary>
        /// <value>The Value.</value>
        public virtual string Value
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets SortIndex.
        /// </summary>
        /// <value>The SortIndex.</value>
        public virtual int SortIndex
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets rowversion.
        /// </summary>
        /// <value>The rowversion.</value>
        public virtual byte[] rowversion
        {
            get;
            set;
        }

        #endregion

        #region Navigation Properties
        public virtual Contact Contact
        {
            get { return _contact; }
            set
            {
                if (!ReferenceEquals(_contact, value))
                {
                    var previousValue = _contact;
                    _contact = value;
                    FixupContact(previousValue);
                }
            }
        }
        private Contact _contact;
        public virtual TelecomType TelecomType
        {
            get { return _telecomType; }
            set
            {
                if (!ReferenceEquals(_telecomType, value))
                {
                    var previousValue = _telecomType;
                    _telecomType = value;
                    FixupTelecomType(previousValue);
                }
            }
        }
        private TelecomType _telecomType;

        #endregion

        #region Association Fixup
    
        private void FixupContact(Contact previousValue)
        {
            if (previousValue != null && previousValue.ContactTelecom.Contains(this))
            {
                previousValue.ContactTelecom.Remove(this);
            }
    
            if (Contact != null)
            {
                if (!Contact.ContactTelecom.Contains(this))
                {
                    Contact.ContactTelecom.Add(this);
                }
                if (FK_Contact != Contact.Id)
                {
                    FK_Contact = Contact.Id;
                }
            }
        }
    
        private void FixupTelecomType(TelecomType previousValue)
        {
            if (previousValue != null && previousValue.ContactTelecom.Contains(this))
            {
                previousValue.ContactTelecom.Remove(this);
            }
    
            if (TelecomType != null)
            {
                if (!TelecomType.ContactTelecom.Contains(this))
                {
                    TelecomType.ContactTelecom.Add(this);
                }
                if (FK_TelecomType != TelecomType.Id)
                {
                    FK_TelecomType = TelecomType.Id;
                }
            }
        }

        #endregion

    }
}
